package com.whmnx.base.adapter;

import android.content.Context;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.RatingBar;

import com.classic.adapter.BaseAdapterHelper;
import com.classic.adapter.CommonRecyclerAdapter;
import com.whmnx.base.R;
import com.whmnx.base.bean.CommentBean;
import com.whmnx.base.utils.ImageUtil;

import java.util.ArrayList;
import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * author : huang
 * date   : 2019/10/21 0021 15:06
 * version: 1.0
 * @author Administrator
 */
public class DynamicAdapter extends CommonRecyclerAdapter<CommentBean> {
    private Context context;
    private List<Boolean> alreadyLikeList = new ArrayList<>();
    private List<String> lists = new ArrayList<>();
    private ImageView view;

    private ReplyListener mReplyListener;

    public void setReplyListener(ReplyListener replyListener) {
        mReplyListener = replyListener;
    }


    public interface ReplyListener {
      //  void commentReplyTopUser(DynamicCommentBean item, int position);

        void commentReplyUser(String item, String forumComentId, int position);

     //   void dianz(DynamicCommentBean item, int position);
    }


    public DynamicAdapter(Context context) {
        super(context, R.layout.item_list_dynamic);
        this.context = context;
    }


    @Override
    public void onUpdate(BaseAdapterHelper helper, CommentBean item, int position) {
        ImageUtil.setImage((CircleImageView)helper.getView(R.id.civ_personal_head_image), (String) item.getUserInfo_Image());
        helper.setText(R.id.tv_name, (String) item.getUserInfo_Name());
        helper.setText(R.id.tv_time, (String) item.getDateTime());
        RatingBar ratingBar = helper.getView(R.id.ratingBar);
        ratingBar.setRating(item.getComment_Praise());
        ratingBar.setClickable(false);
         GridView view = helper.getView(R.id.rv_dynamic_photos);


        helper.setText(R.id.tv_time, (String) item.getDateTime());





        //9宫格图片
        List<String> list = new ArrayList<>();
        FansImagesAdpter fansImagesAdpter = new FansImagesAdpter(context, list);
        view.setAdapter(fansImagesAdpter);
        if (item.getCommentImageModel().size() > 0){
            for (CommentBean.CommentImageModelBean commentImageModelBean : item.getCommentImageModel()) {
                list.add(commentImageModelBean.getImage());
            }
            fansImagesAdpter.notifyDataSetChanged();
        }else {
            fansImagesAdpter.notifyDataSetChanged();
        }
    }
}

